cmake_minimum_required(VERSION 3.23)
project(rtc_client)

set(CMAKE_CXX_STANDARD 17)
option(BUILD_RTC_OHOS "BUILD_RTC_OHOS" OFF)

set(SRC_FILES
        rtc_client.cc
        signaling_client.cc
        json_helper.cc
        http_utils.cc
        rtc_log.cc
        web_socket_client.cc
        peer_connection_channel.cc
        peer_connection_dependency_factory.cc
        ohos_local_stream.cc
        observer/functional_observer.cc
        ohos_video_source_wrapper.cc
        audio/ohos_audio_manager.cc
        nativecpp/local_stream.cc
        nativecpp/peer_connection_channel_native.cc
        nativecpp/peer_connection_dependency_factory_native.cc
        nativecpp/rtc_client_native.cc
        nativecpp/video_source_wrapper.cc
        )

if (BUILD_RTC_OHOS)
    set(SRC_DIRS ${SRC_DIRS}
            client
            render
            capturer
            )
endif()


foreach (tempDir ${SRC_DIRS})
    aux_source_directory(${tempDir} SRC_FILES)
endforeach ()
message("SRC_FILES is ${SRC_FILES}")

add_definitions(-DASIO_STANDALONE)
include_directories(thirdparty)
include_directories(thirdparty/asio/include)

if (BUILD_RTC_OHOS)
    add_definitions(-DOS_OHOS)
    add_library(rtc_client SHARED ${SRC_FILES})

    message("==========>>>2" ${ffmpeg_lib})
    target_link_libraries(rtc_client PUBLIC ${ffmpeg_lib})

    target_link_directories(rtc_client PUBLIC
            ${WEBRTC_ROOT_PATH}/out/ohos_webrtc/obj
            )

    target_link_directories(rtc_client PUBLIC .)
    target_link_libraries(rtc_client PUBLIC -Wl,-Bsymbolic webrtc.a)

    target_link_libraries(rtc_client PUBLIC
            EGL
            GLESv3
            Aki::libjsbind
            libace_napi.z.so
            libace_ndk.z.so
            libhilog_ndk.z.so
            libohaudio.so
            librawfile.z.so
            libohimage.so
            libimage_receiver.so
            libohcamera.so
            libimage_receiver_ndk.z.so
            libnative_image.so
            libnative_media_codecbase.so
            libnative_media_core.so
            libnative_media_venc.so
            libnative_media_vdec.so
            libnative_avscreen_capture.so
            libnative_buffer.so
            libnative_window.so
            libnative_display_manager.so
            libimage_source_ndk.z.so
            )
else()
    include_directories(mock)
    add_executable(rtc_client main.cpp ${SRC_FILES})
endif()
